// 游客模式
const DIRECT_THROUGH_INTERFACE = [
    '/tourist/file/upload'
]
// exclude routers
const CORS_EXCLUDE_ROUTERS = [
    '/user/register',
    '/user/signin',
    '/tourist/file/upload'
]
const ADMIN_EXCLUDE_ROUTERS = [
    '/part/create',
    '/user/create',
    '/user/delete',
    '/user/enable',
    '/user/disable'
]
// ecret key [miaojiankang 6次base64]
const SECRET_KEY = 'VmpGa05HRXlUWGxTYTJoVVYwZDRjVlV3Vmt0WlZscDFZMFprYkZadFVsaFhXSEJIWVZad05WWlljRk5STVZZMlZXdEZiRTB3VVd4Tk1GRWxNMFElM0Q=';
// encryption level
const SALT_ROUNDS = 10;
// database config
const DB_CONF = {
    base: {
        db: 'rdc_mmp',
        name: 'root',
        pwd: 'modh.123'
    },
    param: {
        host: 'localhost',
        dialect: 'mysql',
        dialectOptions: {
            dateStrings: true,
            // 处理读取数据库自动转UTC
            typeCast: (field, next) => {
                if (field.type === 'DATETIME') {
                    return field.string()
                }
                return next()
            }
        },
        timezone: '+08:00',
        pool: {
            max: 20,
            min: 0,
            idle: 10000,
            acquire: 30000
        },
        logging: false
    }
}
// express-session config
const SESSION_CONF = {
    name:'MiaoClientId', //cookie的name，默认值是：connect.sid
    secret: SECRET_KEY, // 建议使用 128 个字符的随机字符串
    cookie: {
        maxAge: 2 * 60 * 60,
        httpOnly: true
    },
    rolling: true,
    resave: false, // 是否每次都重新保存会话，建议false
    saveUninitialized: false // 是否自动保存未初始化的会话，建议false
}
// redis config
const REDIS_CONFIG = {
    post: 6379,
    host: 'localhost',
    opts: {
        db: '7',
        auth_pass: 'qNt-B9FY'
    }
}
// flie upload path
const ALI_OSS_CONF = {
    domain: 'https://ins-test-luban.miao.cn/',
    path: 'test/source/',
    conf: {
        region: 'oss-cn-beijing',
        accessKeyId: 'LTAI4FreCBipvFHTgwCcCEnG',
        accessKeySecret: 'XHgUyFP7HUzt1bsZhXeo4lkZguGpL1',
        bucket: 'ins-test-luban'
    }
}

module.exports = {
    _dti: DIRECT_THROUGH_INTERFACE,
    _cer: CORS_EXCLUDE_ROUTERS,
    _aer: ADMIN_EXCLUDE_ROUTERS,
    _sk: SECRET_KEY,
    _sr: SALT_ROUNDS,
    _dc: DB_CONF,
    _sc: SESSION_CONF,
    _rc: REDIS_CONFIG,
    _aoc: ALI_OSS_CONF
}
